package com.dnjn.happiness.biz.api.factory;

import com.dnjn.happiness.biz.api.RemoteAdviceService;
import com.dnjn.happiness.biz.api.RemoteOutletService;
import com.dnjn.happiness.biz.api.model.OutletModel;
import com.dnjn.happiness.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
public class RemoteOutletFallbackFactory implements FallbackFactory<RemoteOutletService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteOutletFallbackFactory.class);

    @Override
    public RemoteOutletService create(Throwable throwable) {
        log.error("调用解忧馆服务失败：{}" + throwable.getMessage()) ;
        return new RemoteOutletService() {
            @Override
            public R<OutletModel> getLastOutletByUserId(Long userId, String source) {
                return R.fail("查询解忧馆失败: {}" + throwable.getMessage());
            }
        };
    }
}
